//
//  NSManagedObject+Helper.m
//  Sudoku
//
//  Created by Richard Hodgkins on 29/09/2012.
//  Copyright (c) 2012 Richard Hodgkins. All rights reserved.
//

#import "NSManagedObject+Helper.h"

#import <CoreData/CoreData.h>

@implementation NSManagedObject (Helper)

+(NSString *) className
{
    return NSStringFromClass([self class]);
}

+(NSEntityDescription *) entityDescriptionIn:(NSManagedObjectContext *)context
{
    return [NSEntityDescription entityForName:[self className] inManagedObjectContext:context];
}

+(id) insertNewInstanceIn:(NSManagedObjectContext *)context
{
    return [NSEntityDescription insertNewObjectForEntityForName:[[self entityDescriptionIn:context] name] inManagedObjectContext:context];
}

+(NSFetchRequest *) fetchRequestInContext:(NSManagedObjectContext *)context
{
    NSFetchRequest *request = [[NSFetchRequest alloc] init];
    [request setEntity:[self entityDescriptionIn:context]];
    return request;
}

@end
